/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uns.fit.gis.ui;

import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author Nguyen Ngoc Hoan
 */
public class RouteItem extends CustomItem {

    private Sprite turningSprite;
    private String streetName;
    private String length;
    private int width = 200;
    private int height = 32;

    public RouteItem(Sprite turningSprite, String streetName, String length) {
        super("");
        this.turningSprite = new Sprite(turningSprite);
        this.streetName = streetName;
        this.length = length;
    }

    public void setSize(int width, int height) {
        this.width = width;
        this.height = height;
    }

    protected int getMinContentWidth() {
        return height;
    }

    protected int getMinContentHeight() {
        return width;
    }

    protected int getPrefContentWidth(int arg0) {
        return width;
    }

    protected int getPrefContentHeight(int arg0) {
        return height;
    }

    protected void paint(Graphics g, int w, int h) {
        turningSprite.paint(g);
        Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
        g.setFont(font);
        g.drawString(streetName, turningSprite.getX() + turningSprite.getWidth() + 3, 0, Graphics.TOP | Graphics.LEFT);
        int fontHeight = font.getHeight();
        font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_SMALL);
        g.setFont(font);
        g.drawString(length, turningSprite.getX() + turningSprite.getWidth() + 3, fontHeight + 5, Graphics.TOP | Graphics.LEFT);
    }

}
